import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _inherits from "@babel/runtime/helpers/esm/inherits";
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
import React, { Component } from 'react';
import { Provider } from 'mobx-react';
import { getCurrentLanguage, getCurrentRole, getCurrentTenant } from "../../utils/utils";
import { LowCodeSharedComponent } from "../../customize/lowCode";

var LowCodeProvider = /*#__PURE__*/function (_Component) {
  _inherits(LowCodeProvider, _Component);

  var _super = _createSuper(LowCodeProvider);

  function LowCodeProvider() {
    _classCallCheck(this, LowCodeProvider);

    return _super.apply(this, arguments);
  }

  _createClass(LowCodeProvider, [{
    key: "render",
    value: function render() {
      var _getCurrentRole = getCurrentRole(),
          _getCurrentRole$level = _getCurrentRole.level,
          level = _getCurrentRole$level === void 0 ? 'site' : _getCurrentRole$level;

      var _getCurrentTenant = getCurrentTenant(),
          _getCurrentTenant$ten = _getCurrentTenant.tenantId,
          tenantId = _getCurrentTenant$ten === void 0 ? 0 : _getCurrentTenant$ten,
          tenantName = _getCurrentTenant.tenantName;

      var language = getCurrentLanguage();
      var currentLanguage = language.replace('-', '_');
      var AppState = {
        currentLanguage: currentLanguage,
        currentMenuType: {
          type: level,
          organizationId: tenantId,
          id: tenantId,
          name: tenantName
        }
      };
      return /*#__PURE__*/React.createElement(Provider, {
        AppState: AppState
      }, /*#__PURE__*/React.createElement(LowCodeSharedComponent, {
        componentCode: "ModelProvider",
        componentProps: this.props
      }));
    }
  }]);

  return LowCodeProvider;
}(Component);

export { LowCodeProvider as default };